using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class gift_historyMap : EntityTypeConfiguration<gift_history>
    {
        public gift_historyMap()
        {
            // Primary Key
            this.HasKey(t => t.gift_history_id);

            // Properties
            this.Property(t => t.user_id)
                .HasMaxLength(100);

            this.Property(t => t.exchange_postscript)
                .HasMaxLength(200);

            // Table & Column Mappings
            this.ToTable("gift_history");
            this.Property(t => t.gift_history_id).HasColumnName("gift_history_id");
            this.Property(t => t.gift_id).HasColumnName("gift_id");
            this.Property(t => t.exchange_time).HasColumnName("exchange_time");
            this.Property(t => t.user_id).HasColumnName("user_id");
            this.Property(t => t.achieve_flag).HasColumnName("achieve_flag");
            this.Property(t => t.gift_amount).HasColumnName("gift_amount");
            this.Property(t => t.achieve_time).HasColumnName("achieve_time");
            this.Property(t => t.exchange_postscript).HasColumnName("exchange_postscript");

            // Relationships
            this.HasOptional(t => t.gift)
                .WithMany(t => t.gift_history)
                .HasForeignKey(d => d.gift_id);
            this.HasOptional(t => t.user)
                .WithMany(t => t.gift_history)
                .HasForeignKey(d => d.user_id);

        }
    }
}
